package com.andy.customerService.service.impl;



import com.andy.customerService.entity.ProcessLeader;
import com.andy.customerService.mapper.ProcessLeaderMapper;
import com.andy.customerService.service.ProcessLeaderService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 流程负责人表 服务实现类
 * </p>
 *
 * @author Andy
 * @since 2022-02-08
 */
@Service
public class ProcessLeaderServiceImpl extends ServiceImpl<ProcessLeaderMapper, ProcessLeader> implements ProcessLeaderService {

    @Autowired
    private ProcessLeaderMapper processLeaderMapper;

    /**
     * 添加进程管理者
     *
     * @param processLeader
     */
    @Override
    public void addProcessLeader(ProcessLeader processLeader) {
        processLeaderMapper.insert(processLeader);
    }

    /**
     * 修改进程管理者
     *
     * @param processLeader
     */
    @Override
    public void editProcessLeader(ProcessLeader processLeader) {
        processLeaderMapper.updateById(processLeader);
    }

    /**
     * 根据id删除进程管理者
     *
     * @param id
     */
    @Override
    public void deleteProcessLeaderById(Long id) {
        processLeaderMapper.deleteById(id);
    }

    /**
     * 查询管理者列表
     * @return
     */
    @Override
    public List<ProcessLeader> findProcessLeaderList() {
        return processLeaderMapper.selectList(null);
    }

    /**
     * 获取用户角色
     * @param userId
     */
    @Override
    public ProcessLeader getRoleByUserId(String userId) {
        LambdaQueryWrapper<ProcessLeader> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ProcessLeader::getUserId,userId);
        return processLeaderMapper.selectOne(wrapper);
    }
}
